﻿using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Web.Mvc;
using Ctef.Web.Interfaces;
using Ctef.Web.Repositories;

namespace Ctef.Web.Controllers
{
    public class MasterController : Controller
    {
        private readonly IHomepageRepository rep;

        public MasterController()
            : this(new HomepageRepository())
        {
        }

        public MasterController(IHomepageRepository homepageRepository)
        {
            if (homepageRepository == null)
            {
                throw new ArgumentNullException("homepageRepository");
            }

            rep = homepageRepository;
        }

        public ActionResult Slider()
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name;
            var model = rep.GetHomepageModel(culture, Path.Combine(Request.PhysicalApplicationPath, "App_Data"));
            return View(model.Slider.ToArray());
        }

        public ActionResult Footer()
        {
            return View();
        }
    }
}
